package com.igeek.javase.ch04.ordersByTeacher;

/**
 * @author chenmin
 * 2023/7/14 9:06
 * @description 用户信息
 */
public class User {

    private String name;
    private String address;
    private String phone;

    //一对多关联  订单信息
    private Orders[] orders;  //null

    //下单方法
    public void xiaDan(){
        System.out.println("用户姓名："+name);
        System.out.println("用户地址："+address);
        System.out.println("用户手机号："+phone);

        System.out.println("============订单信息===========");
        if(orders!=null){
            //foreach迭代  for(元素类型 临时变量名 : 数组名){}
            for (Orders order : orders) {
                if(order!=null){
                    System.out.println("订单编号："+order.getNo());
                }
            }
        }
    }

    public User() {
    }

    public User(String name, String address, String phone) {
        this.name = name;
        this.address = address;
        this.phone = phone;
    }

    public User(String name, String address, String phone, Orders[] orders) {
        this.name = name;
        this.address = address;
        this.phone = phone;
        this.orders = orders;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return address
     */
    public String getAddress() {
        return address;
    }

    /**
     * 设置
     * @param address
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * 获取
     * @return phone
     */
    public String getPhone() {
        return phone;
    }

    /**
     * 设置
     * @param phone
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * 获取
     * @return orders
     */
    public Orders[] getOrders() {
        return orders;
    }

    /**
     * 设置
     * @param orders
     */
    public void setOrders(Orders[] orders) {
        this.orders = orders;
    }

    /*public String toString() {
        return "User{name = " + name + ", address = " + address + ", phone = " + phone + ", orders = " + Arrays.toString(orders) + "}";
    }*/
}
